home *** CD-ROM | disk | FTP | other *** search
- ;Sprite Example (AGA only)
- ;-------------------------
- ;This example contains four 64 pixel wide sprites, in high resolution.
- ;You can move sprite number 2 around with the mouse, notice how it
- ;appears behind number 1 and in front of 3 and 4.
- ;
- ;This demo also uses the LIST feature to initialise the four sprites.
- ;
- ;The LMB exits the demo.
-
- opt o+,c+,d-
-
- INCLUDE "exec/exec_lib.i"
- INCLUDE "games/games_lib.i"
- INCLUDE "games/games.i"
-
- CALL MACRO
- jsr _LVO\1(a6)
- ENDM
-
- SECTION "Sprites",CODE
-
- ;===========================================================================;
- ; INITIALISE DEMO
- ;===========================================================================;
-
- Start: MOVEM.L A0-A6/D1-D7,-(SP)
- move.l ($4).w,a6
- lea GMS_Name(pc),a1
- moveq #$00,d0
- CALL OpenLibrary
- move.l d0,GMS_Base
- beq.s Error
-
- move.l GMS_Base(pc),a6 ;Run this demo at a user-selected
- CALL SetUserPri ;priority.
-
- lea ScreenStruct(pc),a0 ;Initialise our screen for use.
- CALL Add_Screen
- tst.l d0
- bne.s Error
-
- CALL Show_Screen ;Show our screen.
-
- lea SpriteList(pc),a1
- CALL Init_Sprite
-
- lea Circle1(pc),a1
- CALL Update_Sprite
- lea Circle3(pc),a1
- CALL Update_Sprite
- lea Circle4(pc),a1
- CALL Update_Sprite
-
- moveq #JPORT1,d0 ;Read from port 1
- CALL Read_Mouse ;Initialise the port.
-
- ;===========================================================================;
- ; MAIN LOOP
- ;===========================================================================;
-
- lea Circle2(pc),a1
-
- Loop: moveq #JPORT1,d0 ;Read from port 1
- CALL Read_Mouse ;Go get mouse position.
- move.w d0,d1
- asr.w #8,d0
- add.w d0,SPR_XPos(a1)
- ext.w d1
- add.w d1,SPR_YPos(a1)
-
- CALL Wait_OSVBL ;Allow screen-switching.
- CALL Update_Sprite ;Put Sparkie on the screen.
-
- btst #MB_LMB,d0
- beq.s Loop
-
- ;===========================================================================;
- ; RETURN TO DOS
- ;===========================================================================;
-
- ReturnToDOS:
- move.l GMS_Base(pc),a6
- lea ScreenStruct(pc),a0
- CALL Delete_Screen ;Give back screen memory etc.
- Error: move.l GMS_Base(pc),a1
- move.l ($4).w,a6
- CALL CloseLibrary
- Quit: MOVEM.L (SP)+,A0-A6/D1-D7
- moveq #$00,d0
- rts
-
- ;===========================================================================;
- ; DATA
- ;===========================================================================;
-
- GMS_Name:
- dc.b "games.library",0
- even
- GMS_Base:
- dc.l 0
-
- SpriteList:
- dc.l "LIST"
- dc.l Circle1
- dc.l Circle2
- dc.l Circle3
- dc.l Circle4
- dc.l LISTEND
-
- Circle1 dc.l "SPV1",0 ;Structure version.
- dc.w 0 ;Bank Number 0.
- dc.l Gfx_Circle1 ;Ptr to graphic.
- dc.w 20,20 ;Beginning X/Y position
- dc.w 0 ;Current frame.
- dc.w 64 ;Width (16/32/64)
- dc.w 64 ;Height
- dc.w 16 ;Amt of colours.
- dc.w 16 ;Colour start in palette.
- dc.w 2 ;Amt of planes.
- dc.w LORES ;Attributes.
- dc.w 0 ;PlayField position.
- dc.l 0,0 ;Private.
-
- Circle2 dc.l "SPV1",0 ;Structure version.
- dc.w 2 ;Bank Number 2.
- dc.l Gfx_Circle2 ;Ptr to graphic.
- dc.w 70,70 ;Beginning X/Y position
- dc.w 0 ;Current frame.
- dc.w 64 ;Width (16/32/64)
- dc.w 64 ;Height
- dc.w 16 ;Amt of colours.
- dc.w 16 ;Colour start in palette.
- dc.w 2 ;Amt of planes.
- dc.w LORES ;Attributes.
- dc.w 0 ;PlayField position.
- dc.l 0,0 ;Private.
-
- Circle3 dc.l "SPV1",0 ;Structure version.
- dc.w 4 ;Bank Number 4.
- dc.l Gfx_Circle3 ;Ptr to graphic.
- dc.w 120,120 ;Beginning X/Y position
- dc.w 0 ;Current frame.
- dc.w 64 ;Width (16/32/64)
- dc.w 64 ;Height
- dc.w 16 ;Amt of colours.
- dc.w 16 ;Colour start in palette.
- dc.w 2 ;Amt of planes.
- dc.w LORES ;Attributes.
- dc.w 0 ;PlayField position.
- dc.l 0,0 ;Private.
-
- Circle4 dc.l "SPV1",0 ;Structure version.
- dc.w 6 ;Bank Number 4.
- dc.l Gfx_Circle4 ;Ptr to graphic.
- dc.w 170,170 ;Beginning X/Y position
- dc.w 0 ;Current frame.
- dc.w 64 ;Width (16/32/64)
- dc.w 64 ;Height
- dc.w 16 ;Amt of colours.
- dc.w 16 ;Colour start in palette.
- dc.w 2 ;Amt of planes.
- dc.w HIRES ;Attributes.
- dc.w 0 ;PlayField position.
- dc.l 0,0 ;Private.
-
- AMT_PLANES = 1
-
- ScreenStruct:
- dc.l "GSV1",0
- dc.l 0,0,0 ;Screen_Mem1/2/3
- dc.l 0 ;Screen link.
- dc.l ScreenPalette ;Address of the screen palette.
- dc.l 0 ;Address of a ColourList.
- dc.l 32 ;Amt of colours in the palette.
- dc.w 320,256,320,256 ;Screen & Pic Height/Width
- dc.w AMT_PLANES ;Amt_Planes
- dc.w 0,0 ;X/Y Top Of Screen
- dc.w 0,0 ;X/Y Pic Offsets (for scrolling).
- dc.l SPRITES|NOSPRBDR ;Special attributes.
- dc.w LORES|COL24BIT ;Screen mode.
- dc.b INTERLEAVED ;Screen type
- dc.b 0 ;Reserved.
- even
-
- ScreenPalette:
- dc.l $00000000,$000F0000,$001F0000,$002F0000
- dc.l $003F0000,$004F0000,$005F0000,$006F0000
- dc.l $007F0000,$008F0000,$009F0000,$00AF0000
- dc.l $00BF0000,$00CF0000,$00DF0000,$00EF0000
- dc.l $00FF0000,$00001111,$00002222,$00003333
- dc.l $00004444,$00005555,$00006666,$00007777
- dc.l $00008888,$00009999,$0000AAAA,$0000BBBB
- dc.l $0000CCCC,$0000DDDD,$0000EEEE,$0000FFFF
-
- ;===========================================================================;
- ; ALL CHIP RAM DATA HERE
- ;===========================================================================;
-
- SECTION "Graphics",DATA_C
-
- CNOP 0,4 ;Sprite must be 64bit aligned.
- Gfx_Circle1:
- INCBIN "GAMESLIB:data/CircleSpr1.raw"
-
- CNOP 0,4 ;Sprite must be 64bit aligned.
- Gfx_Circle2:
- INCBIN "GAMESLIB:data/CircleSpr2.raw"
-
- CNOP 0,4 ;Sprite must be 64bit aligned.
- Gfx_Circle3:
- INCBIN "GAMESLIB:data/CircleSpr3.raw"
-
- CNOP 0,4 ;Sprite must be 64bit aligned.
- Gfx_Circle4:
- INCBIN "GAMESLIB:data/CircleSpr3.raw"
-
-
-